package top.xianggg.xservers.sys.entity;

import lombok.*;
import top.xianggg.xservers.common.base.jpa.BaseEntity;

import javax.persistence.*;
import java.io.Serializable;
import java.util.List;

/**
 * @author Jr.November
 * 用户状态,0:创建未认证（比如没有激活，没有输入验证码等等）--等待验证的用户 , 1:正常状态,2：用户被锁定.
 */
@Entity
@EqualsAndHashCode(callSuper = false)
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString(exclude = "roleList")
public class SysUser extends BaseEntity {
    @Column(unique = true)
    protected String username;
    protected String name;
    protected String password;
    /**
     * 加密密码的盐
     */
    protected String salt;
    /**
     * 一个用户具有多个角色
     * 立即从数据库中进行加载数据
     */
    @ManyToMany(fetch= FetchType.EAGER)
    @JoinTable(name = "SysUserRole", joinColumns = { @JoinColumn(name = "uid") }, inverseJoinColumns ={@JoinColumn(name = "roleId") })
    private List<SysRole> roleList;
}
